<?php
// +----------------------------------------------------------------------
// | Author: wyd 2025/10/13
// | DESC: 
// +----------------------------------------------------------------------

declare (strict_types=1);


namespace My\app\controllers;

use My\core\annotations\ClassAnnotation;
use My\core\annotations\DbAnnotation;
use My\core\annotations\MethodAnnotation;
use My\core\annotations\PropertyAnnotation;
use My\core\frame\DbManager;
use My\core\http\Request;

//使用php8注解

#[ClassAnnotation(alias:"",name: 'u')]         //使用Bean注解
class User
{
    public $name = 'user23';

    #[PropertyAnnotation(version:'version')]
    public $version = '45';


    /**
     * @var DbManager
     */
    #[DbAnnotation(connect: '')]
    public $db;

    /**
     * @var DbManager
     */
    #[DbAnnotation(connect: 'test')]
    public $db1;

    /**
     * @var DbManager
     */
    #[DbAnnotation(connect: 'test1')]
    public $db2;

    #[MethodAnnotation(uri: "/test/{uid:\d+}",method: 'GET')]
    public function test(int $uid, Request $request)
    {
        return $this->db->table('user')->first();

       // return ['uid'=>3, 'name'=>'张三'];
    }

    #[MethodAnnotation(uri: "/test1/{uid:\d+}",method: 'GET')]
    public function test1(int $uid, Request $request)
    {
        return $this->db1->table('user')->first();
    }

    #[MethodAnnotation(uri: "/test2/{uid:\d+}",method: 'GET')]
    public function test2(int $uid, Request $request)
    {
        return $this->db2->table('user')->first();
    }
}